package com.travelgroup.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.travelgroup.domain.dto.LocationDTO;
import com.travelgroup.domain.entity.District;
import com.travelgroup.domain.entity.Location;
import com.travelgroup.exception.R;
import com.travelgroup.service.ILocationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/location")
@Tag(name = "地点信息模块")
public class LocationController {
    @Resource
    private ILocationService locationService;

    @PostMapping("/administrative")
    @Operation(summary = "行政区划搜索")
    public R<List<District>> getAdministrative(@RequestParam(defaultValue = "1") Integer current,
                                               @RequestParam(defaultValue = "20") Integer size,
                                               @RequestBody LocationDTO searchDTO) throws JsonProcessingException {
        return locationService.getAdministrative(current, size, searchDTO);
    }

    @PostMapping("/attraction")
    @Operation(summary = "获取行政区划内景点")
    public R<List<Location>> getAttraction(@RequestParam(defaultValue = "1") Integer current,
                                           @RequestParam(defaultValue = "20") Integer size,
                                           @RequestBody LocationDTO searchDTO) throws JsonProcessingException {
        return locationService.getAttractions(current, size, searchDTO);
    }

}
